package chapter18;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author liuziyang
 * @create 2019-03-31 21:56
 */
public class StoreCASState {
    public static void main(String[] args) throws IOException {
        /*List<Class<? extends Shape>> shapeTypes = new ArrayList<>();
        shapeTypes.add(Circle.class);
        shapeTypes.add(Square.class);
        shapeTypes.add(Line.class);*/

        List<Shape> shapes = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            shapes.add(Shape.randomFactory());
        }

        //set all the static colors to green
        for (int i = 0; i < 10; i++) {
            shapes.get(i).setColor(Shape.GREEN);
        }

        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("CADState.out"));
//        out.writeObject(shapeTypes);
        Line.serializeStaticState(out);
        Square.serializeStaticState(out);
        Circle.serializeStaticState(out);
        out.writeObject(shapes);

        System.out.println(shapes);
    }
}
